<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.w3.org/1999/xhtml">
<head th:replace="admin/_fragments :: head(~{::title})">
    <meta charset="UTF-8">
    <meta name="viewpoint" content="width=device-width, initial-scale=1.0">
    <title>博客管理</title>
    <link href="https://cdn.bootcss.com/semantic-ui/2.4.1/semantic.min.css" rel="stylesheet">
    <link href="../../static/css/myCss.css" rel="stylesheet">
</head>
<body>
<nav th:replace="admin/_fragments :: menu(1)" class="ui inverted attached segment my-padding-tb-mini my-shadow-small">
    <div class="ui container">
        <div class="ui inverted secondary menu stackable">
            <h2 class="ui header teal item">管理后台</h2>
            <a href="#" class="active my-item item my-mobile-hide">博客</a>
            <a href="#" class="my-item item my-mobile-hide">标签</a>
            <a href="#" class="my-item item my-mobile-hide">分类</a>

            <!--            头像-->
            <div class="my-item right menu my-mobile-hide">
                <div class="ui dropdown item">
                    <div class="text">
                        <img class="ui avatar image QR" src="../../static/images/pika.jpg">
                        登陆者用户名
                    </div>
                    <i class="dropdown icon"></i>
                    <div class="menu">
                        <a href="#" class="item">注销</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <a href="#" class="menu tooggle ui icon black button my-top-right my-mobile-show"><i class="sidebar icon"></i></a>
</nav>

<div class="ui menu attached pointing animated fadeInDown">
    <div class="ui container">
        <div class="right menu">
            <a th:href="@{/admin/blogs/input}" class="teal item">发布</a>
            <a class="active item teal">列表</a>
        </div>
    </div>
</div>

<div class="my-padding-tb-large my-container-small animated fadeInUp">
    <div class="ui container">
<!--        <div id="table-container">-->
<!--            <form class="ui segment form">-->
<!--                <div class="inline fields animated fadeInUp">-->
<!--                    <div class="field">-->
<!--                        <input type="text" name="title" placeholder="标题">-->
<!--                    </div>-->

<!--                    <div class="field">-->
<!--                        <div class="ui labeled action input">-->
<!--                            <div class="ui type selection dropdown">-->
<!--                                <input name="type" type="hidden">-->
<!--                                <i class="dropdown icon"></i>-->
<!--                                <div class="default text">分类</div>-->
<!--                                <div class="menu">-->
<!--                                    <div th:each="type : ${types}" class="item" data-value="1" th:data-value="${type.id}" th:text="${type.typeName}">错误日志</div>-->
<!--                                    &lt;!&ndash;/*&ndash;&gt;-->
<!--                                    <div class="item" data-value="1">开发手册</div>-->
<!--                                    &lt;!&ndash;*/&ndash;&gt;-->
<!--                                </div>-->
<!--                            </div>-->
<!--                        </div>-->
<!--                        <button class="ui clear button">清除</button>-->
<!--                    </div>-->

<!--                    <div class="field">-->
<!--                        <button id="search-btn" type="button" class="ui button basic teal"><i class="icon search"></i>搜索-->
<!--                        </button>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </form>-->
<!--        </div>-->

        <table class="ui table celled animated fadeInUp">
            <thead class="center aligned">
            <tr>
                <th></th>
                <th>标题</th>
                <th>状态</th>
                <th>更新时间</th>
                <th>操作</th>
            </tr>
            </thead>

            <tbody class="center aligned">
            <tr th:each="blog,iterStat : ${page.content}">
                <td th:text="${iterStat.count}">1</td>
                <td th:text="${blog.title}">刻意练习清单</td>
                <td th:text="${blog.type.typeName}">认知升级</td>
                <td th:text="${blog.updateTime}">2017-10-02 09:45</td>
                <td>
                    <a href="#" th:href="@{/admin/blogs/{id}/input(id=${blog.id})}" class="ui mini teal basic button">编辑</a>
                    <a href="#" th:href="@{/admin/blogs/{id}/delete(id=${blog.id})}" class="ui mini red basic button">删除</a>
                </td>


            </tr>
            </tbody>

            <tfoot>
            <tr>
                <th colspan="6">
                    <div class="ui mini pagination menu" th:if="${page.totalPages}>1" >
                        <a th:href="@{/admin/blogs(page=${page.number}-1)}" class="item" th:unless="${page.first}">上一页</a>
                        <a th:href="@{/admin/blogs(page=${page.number}+1)}" class=" item" th:unless="${page.last}">下一页</a>
                    </div>
                    <a href="#" th:href="@{/admin/blogs/input}" class="ui mini right floated teal basic button">新增</a>
                </th>
            </tr>
            </tfoot>
        </table>

        <div class="ui success message" th:unless="${#strings.isEmpty(message)}">
            <i class="close icon"></i>
            <div class="header">提示：</div>
            <p th:text="${message}">恭喜，操作成功！</p>
        </div>

    </div>
</div>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/semantic-ui/2.4.1/semantic.min.js"></script>
<script>
    $('.menu.tooggle').click(function () {
        $('.my-item').toggleClass('my-mobile-hide');
    });

    $('.ui.dropdown')
        .dropdown({
            on: "hover"
        });

    $('.message .close')
        .on('click', function () {
            $(this)
                .closest('.message')
                .transition('fade');
        });


    function page(obj) {
        $("[name='page']").val($(obj).data("page"));
        loaddata();
    }

    // function loaddata() {
    //     $('#table-container').load("/admin/blogs/search", {
    //         title: $("[name='title']").val(),
    //         typeId: $("[name='typeId']").val(),
    //         page: $("[name='page']").val()
    //     });
    // }
    //
    // $('#search-btn').click(function () {
    //     loaddata();
    // });
    //
    // $('.clear .button')
    //     .on('click', function () {
    //         $('.type .ui.dropdown')
    //             .dropdown('clear')
    //         ;
    //     })
    // ;

</script>
</body>
</html>